package testes;

public class Arvore {
	
	private Node raiz;
	
	public Arvore(Node raiz){
		this.raiz = raiz;
	}
	
	private void insert(Node raiz, Node no){
		if(raiz.key >= no.key){
			if(raiz.left == null){
				raiz.left = no;
				no.parent = raiz;
			}else{
				insert(raiz.left, no);
			}
		}else{
			if(raiz.right == null){
				raiz.right = no;
				no.parent = raiz;
			}else{
				insert(raiz.right, no);
			}
		}
	}
	
	public void add(int key){
		if(raiz != null){
			insert(raiz, new Node(key));
		}else{
			raiz = new Node(key);
		}
	}

}
